<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%--
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
--%>

<!DOCTYPE html>

<html lang="zh-cn">
<head>
    <title>查看供应商</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="author" content="陈芳杰（baayso@qq.com）"/>

    <link rel="stylesheet" href="${ pageContext.request.contextPath }/jsp/lib/quick.css"/>
    <link rel="stylesheet" href="${ pageContext.request.contextPath }/jsp/css/public.css"/>
    <script type="text/javascript" src="${ pageContext.request.contextPath }/jsp/lib/jquery.js"></script>
    <script type="text/javascript" src="${ pageContext.request.contextPath }/jsp/lib/jquery.maskedinput.js"></script>

    <script type="text/javascript">

        jQuery(function($) {
        			$("#telephone").mask("099 99999999", {placeholder:"-"});
        			$("#fax").mask("099 99999999", {placeholder:"-"});
        		});

        function enableEdit() {
            var $btnEdit = $("#btnEdit");
            var $btnSave = $("#btnSave");
            var $name = $("#name");
            var $contact = $("#contact");
            var $telephone = $("#telephone");
            var $fax = $("#fax");
            var $address = $("#address");
            var $descriptions = $("#descriptions");

            if ("编辑" == $btnEdit.text()) {
                // 将页面上的控件置为可用
                $name.attr("disabled", false);
                $contact.attr("disabled", false);
                $telephone.attr("disabled", false);
                $address.attr("disabled", false);
                $fax.attr("disabled", false);
                $descriptions.attr("disabled", false);
                $btnEdit.text("取消");
                $btnSave.fadeIn("slow");
            }
            else {
                // 将页面上的控件置为不可用
               	$name.attr("disabled", true);
                $contact.attr("disabled", true);
                $telephone.attr("disabled", true);
                $address.attr("disabled", true);
                $fax.attr("disabled", true);
                $descriptions.attr("disabled", true);
                $btnEdit.text("编辑");
                $btnSave.fadeOut("slow");
            }

        }

        function del(id) {
        	if (confirm("确定删除供应商信息吗？")) {
				location.href = "${ pageContext.request.contextPath }/jsp/supplier/SupplierServlet?method=DEL&id=" + id;
			}
        }
        
        function update() {
        	if (confirm("确定要保存修改的供应商信息吗？")) {
        		$("#updateSupplierForm").submit();
			}
        }

    </script>
</head>

<body>

<div class="list">

    <div class="add">
        <span class="font_size_13">
            <a href="javascript:void(0);" class="label label-blue">查看供应商 &gt;&gt;</a>
        </span>
    </div>

    <div class="col-1-1">
        <form id="updateSupplierForm" name="updateSupplierForm" class="form form-stacked" method="post" action="${ pageContext.request.contextPath }/jsp/supplier/SupplierServlet?method=UPDATE">
            <fieldset>

                <div class="grid">
                	<%--
                    <div class="col-1-2">
                        <label>供应商编号：</label>
                        <input type="text" placeholder="供应商编号" value="${ supplier.id }" disabled/>
                    </div>
                    --%>

                    <input type="hidden" name="id" value="${ supplier.id }"/>

                    <div class="col-1-2">
                        <label><span style="color: red;">*</span>供应商名称：</label>
                        <input type="text" id="name" name="name" placeholder="供应商名称" value="${ supplier.name }" disabled/>
                        <!-- <span style="color: red;">供应商名称不能空！</span> -->
                    </div>

                    <div class="col-1-2">
                        <label>联系人：</label>
                        <input type="text" id="contact" name="contact" placeholder="联系人" value="${ supplier.contact }" disabled/>
                    </div>

                    <div class="col-1-2">
                        <label>电话号码：</label>
                        <input type="text" id="telephone" name="telephone" placeholder="电话号码" value="${ supplier.tel }" disabled/>
                    </div>

                    <div class="col-1-2">
                        <label>传真号码：</label>
                        <input type="text" id="fax" name="fax" placeholder="传真号码" value="${ supplier.fax }" disabled/>
                    </div>

                    <div class="col-1-2">
                        <label>供应商地址：</label>
                        <textarea id="address" name="address" rows="2" class="x1-large" placeholder="供应商地址" disabled>${ supplier.address }</textarea>
                    </div>

                    <div class="col-1-2">
                        <label>备注：</label>
                        <textarea id="descriptions" name="descriptions" rows="2" class="x1-large" placeholder="备注" disabled>${ supplier.descriptions }</textarea>
                    </div>

                    <div class="col-1-1 width_830">
                        <!-- <button type="submit" class="button-blue">提交数据</button> -->
                        <a href="javascript:void(0);" id="btnEdit" class="button button-blue" onclick="enableEdit();">编辑</a>
                        <a href="javascript:void(0);" id="btnSave" class="button button-green" onclick="update();" style="display: none;">保存</a>
                        <a href="javascript:void(0);" onclick="del('${supplier.id}');" class="button button-red">删除</a>
                        <a href=
                            <c:choose>
                                <c:when test="${'BILL'==requestScope.parent}"
                            "${ pageContext.request.contextPath }/jsp/supplier/SupplierServlet?method=LIST"
                            </c:choose>
                            class="button button-red">返回</a>
                    </div>
                </div>

            </fieldset>
        </form>
    </div>

</div>

</body>

</html>